<template>
	<view class="content">
		<view class="top flexs2">
			<block v-if='uid'>
				<image class="top_img" :src="usermsg.avatar || '../../static/logo.png'"></image>
				<view class="text-bold">{{usermsg.nickname}}</view>
			</block>
			<block v-else>
			<view class="text-white weiDL">未登录</view>
			</block>
		</view>
		<view class="con flexs1">
			<view class="cona" @click="balance">
				<view class="text-red text-bold">{{usermsg.money}}</view>
				<view class="small">余额</view>
			</view>
			<view class="cona" @click="coupons">
				<view class="text-red text-bold">{{couponscount}}</view>
				<view class="small">优惠券</view>
			</view>
			<view class="cona" @click="integral">
				<view class="text-red text-bold">{{usermsg.score}}</view>
				<view class="small">积分</view>
			</view>
		</view>
		<view class="bot">
			<view class="list flexs1" @click="topUp">
				<view class="list_left flexs3">
					<image class="l_img" src="../../static/img/cz.png"></image>
					<view>充值</view>
				</view>
				<view class="cuIcon-right text-gray"></view>
			</view>
			<view class="list flexs1" @click="address">
				<view class="list_left flexs3">
					<image class="l_img" src="../../static/img/dz.png"></image>
					<view>地址管理</view>
				</view>
				<view class="cuIcon-right text-gray"></view>
			</view>
			<view class="list flexs1">
				<view class="list_left flexs3" @click="kefu">
					<image class="l_img" src="../../static/img/kefu.png"></image>
					<view>在线客服</view>
				</view>
				<view class="cuIcon-right text-gray"></view>
			</view>
			<view class="list flexs1" @click="aboutUs">
				<view class="list_left flexs3">
					<image class="l_img" src="../../static/img/guanyu.png"></image>
					<view>关于我们</view>
				</view>
				<view class="cuIcon-right text-gray"></view>
			</view>
			<view class="list flexs1">
				<view class="list_left flexs3">
					<image class="l_img" src="../../static/img/phone.png"></image>
					<view>客服电话</view>
				</view>
				<view><text>{{configmsg.kefu_mobile}}</text><text class="cuIcon-right text-gray"></text></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid:'',
				token:'',
				usermsg:[],
				urls: this.$common.baseUrl,
				couponscount:'',
				configmsg:''
			}
		},
		onLoad(option) {
			if(option.uid){
				this.uid = option.uid;
				uni.setStorageSync('uid', this.uid);
			}
			if(option.token){
				this.token = option.token;
				uni.setStorageSync('token', this.token);
			}
		},
		onShow() {
			this.getusermsg();
		},
		methods: {
			//获取用户信息
			getusermsg(){
				if(uni.getStorageSync('uid')){
					this.uid = uni.getStorageSync('uid');
				}
				var obj = {
				}
				this.$common.requests('/api/Order/getusermsg',obj).then(res =>{
					if(res.data.code == 1){
						this.usermsg = res.data.data.usermsg;
						this.couponscount = res.data.data.coupons;
					}else{
						this.$api.msg(res.data.msg)
						// uni.navigateTo({
						// 	url:'../login/login'
						// })
						
					}
				})
				this.$common.requests('/api/shop/getconfigmsg').then(res =>{
					if(res.data.code == 1){
						this.configmsg = res.data.data;
					}else{
						this.$api.msg(res.data.msg)
					}
				})
			},
			//余额
			balance(){
				uni.navigateTo({
					url:'../balance/balance'
				})
			},
			//优惠券
			coupons(){
				uni.navigateTo({
					url:'../coupons/coupons'
				})
			},
			//积分
			integral(){
				uni.navigateTo({
					url:'../integral/integral'
				})
			},
			//充值
			topUp(){
				uni.navigateTo({
					url:'../topUp/topUp'
				})
			},
			//地址管理
			address(){
				uni.navigateTo({
					url:'../address/address'
				})
			},
			//关于我们
			aboutUs(){
				uni.navigateTo({
					url:'../aboutUs/aboutUs'
				})
			},
			kefu(){
				window.location.href = 'http://w10.ttkefu.com/k/linkurl/?t=3B1FGAE5'
			}
		}
	}
</script>

<style>
	page{
		background: #F9F9F9;
	}
	.content{
		width: 100vw;
	}
	.top{
		width: 100%;
		height: 25vh;
		background: #14C7CE;
		color: #FFFFFF;
		flex-direction: column;
	}
	.top_img{
		width: 140upx;
		height: 140upx;
		margin: 50upx 0 15upx 0;
		border-radius: 10upx;
	}
	.weiDL{
		background: #E4E4E4;
		border-radius: 30upx;
		font-size: 30upx;
		padding: 6upx 30upx 10upx 30upx;
		letter-spacing: 5upx;
	}
	.con{
		padding: 20upx 0;
		background: #FFFFFF;
	}
	.cona{
		width: 33%;
		text-align: center;
		
	}
	.small{
		font-size: 28upx;
		margin-top: 10upx;
	}
	.bot{
		margin-top: 20upx;
		background: #FFFFFF;
		padding: 0 30upx;
	}
	.list{
		padding: 35upx 0;
		border-bottom: 1px solid #E9E9E9;
	}
	.l_img{
		width: 35upx;
		height: 35upx;
		margin-right: 20upx;
	}
</style>
